package com.ruoyi.web.controller.yjgl;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yjgl.domain.TbYjglBjjl;
import com.ruoyi.yjgl.service.ITbYjglBjjlService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报警记录Controller
 * 
 * @author ruoyi
 * @date 2023-11-11
 */
@RestController
@RequestMapping("/yjgl/bjjl")
public class TbYjglBjjlController extends BaseController
{
    @Autowired
    private ITbYjglBjjlService tbYjglBjjlService;

    /**
     * 查询报警记录列表
     */
    @PreAuthorize("@ss.hasPermi('yjgl:bjjl:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbYjglBjjl tbYjglBjjl)
    {
        startPage();
        List<TbYjglBjjl> list = tbYjglBjjlService.selectTbYjglBjjlList(tbYjglBjjl);
        return getDataTable(list);
    }
    @GetMapping("/list1")
    public List<TbYjglBjjl> list()
    {

        List<TbYjglBjjl> list = tbYjglBjjlService.selectTbYjglBjjlList1();
        return list;
    }

    /**
     * 导出报警记录列表
     */
    @PreAuthorize("@ss.hasPermi('yjgl:bjjl:export')")
    @Log(title = "报警记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbYjglBjjl tbYjglBjjl)
    {
        List<TbYjglBjjl> list = tbYjglBjjlService.selectTbYjglBjjlList(tbYjglBjjl);
        ExcelUtil<TbYjglBjjl> util = new ExcelUtil<TbYjglBjjl>(TbYjglBjjl.class);
        util.exportExcel(response, list, "报警记录数据");
    }

    /**
     * 获取报警记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('yjgl:bjjl:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbYjglBjjlService.selectTbYjglBjjlById(id));
    }

    /**
     * 新增报警记录
     */
    @PreAuthorize("@ss.hasPermi('yjgl:bjjl:add')")
    @Log(title = "报警记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbYjglBjjl tbYjglBjjl)
    {
        return toAjax(tbYjglBjjlService.insertTbYjglBjjl(tbYjglBjjl));
    }

    /**
     * 修改报警记录
     */
    @PreAuthorize("@ss.hasPermi('yjgl:bjjl:edit')")
    @Log(title = "报警记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbYjglBjjl tbYjglBjjl)
    {
        return toAjax(tbYjglBjjlService.updateTbYjglBjjl(tbYjglBjjl));
    }

    /**
     * 删除报警记录
     */
    @PreAuthorize("@ss.hasPermi('yjgl:bjjl:remove')")
    @Log(title = "报警记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbYjglBjjlService.deleteTbYjglBjjlByIds(ids));
    }
}
